001    package jgb.examples.eventhandlers;
002    
003    import jgb.examples.SwingSetWindow;
004    import jgb.examples.models.SSModel;
005    
006    import javax.swing.*;
007    import java.beans.PropertyChangeEvent;
008    import java.beans.PropertyVetoException;
009    
010    public class SwingSetEvent {
011        public void validateCommand(PropertyChangeEvent e, SwingSetWindow w)
012                throws PropertyVetoException {
013            String newVal = (String)e.getNewValue();
014            SSModel model = w.getModel();
015            if (model.getInvalidCommand().equals(newVal)) {
016                throw new PropertyVetoException("Invalid Command", e);
017            }
018        }
019    
020        public void updateStatus(PropertyChangeEvent e, SwingSetWindow w) {
021            SSModel model = w.getModel();
022            model.setModelState("<html><body>Command = " + model.getCommand() + "<p>" + "Invalid Command = " + model.getInvalidCommand() + "<p>EnableCommand = " + model.getEnableCommand() + "<p>enableCheckbox = " + model.getEnableCheckbox() + "</body></html>");
023        }
024    
025        public void modifyCheckbox(PropertyChangeEvent e, SwingSetWindow w) {
026            SSModel model = w.getModel();
027            JComboBox c = w.getCombobox();
028            c.setEnabled(model.getEnableCheckbox().equals("Y"));
029        }
030    
031        public void modifyCommand(PropertyChangeEvent e, SwingSetWindow w) {
032            SSModel model = w.getModel();
033            JTextField f = w.getCommand();
034            f.setEnabled(!model.getEnableCommand());
035        }
036    }
037